import type { App, Component } from 'vue'
// import './style/index.less'
import IButton from './packages/components/IButton'
import IColumnHover from './packages/components/IColumnHover'
import ICard from './packages/components/ICard'
import IUpload from './packages/components/IUpload'
import IDialog from './packages/components/IDialog'
import IFlexHeaderMain from './packages/components/IFlexHeaderMain'
import IFlexLeftRight from './packages/components/IFlexLeftRight'
import IForm from './packages/components/IForm'
import IMenu from './packages/components/IMenu'
import ISearch from './packages/components/ISearch'
import ISeniorSearch from './packages/components/ISeniorSearch'
import ITabs from './packages/components/ITabs'
import ITree from './packages/components/ITree'
import IVxeTable from './packages/components/IVxeTable'
import ITable from './packages/components/ITable'
import IDrawer from './packages/components/IDrawer'
import { useMessage } from './packages/components/sysMsg/sysMsg'
const components: {
  [propName: string]: Component
} = {
  IButton, IDialog, IColumnHover,IUpload, ICard,IFlexHeaderMain, IFlexLeftRight, IForm, IMenu, ISearch, ISeniorSearch, ITabs, ITree, IVxeTable,ITable, useMessage,IDrawer
}

// 插件声明：声明所有插件
// 插件注册：在 Vue 项目的入口文件中，通过 ( app.use(插件) ) 进行注册
const installComponents: any = (app: App) => {
  for (const key in components) {
    app.component(key, components[key])
  }
}
// vue插件
// - install：每个插件都有一个 install 方法
// - 参数：是通过 Vue.createApp() 创建的 app 实例
const install: any = (app: any, router?: any) => {
  // !router && installRouter(app);
  installComponents(app)
}
// @ts-ignore
if (typeof window !== "undefined" && window.Vue) {
  // @ts-ignore
  install(window.Vue)
}
export default {
  install
}
export {
  IButton,
  IDialog,
  IColumnHover,
  ICard,
  IUpload,
  IFlexHeaderMain,
  IFlexLeftRight,
  IForm,
  IMenu,
  ISearch,
  ISeniorSearch,
  ITabs,
  ITree,
  IVxeTable,
  ITable,
  useMessage,
  IDrawer
}
